package com.yunze.apiCommon.upstreamAPI.ChenZe.Inquire;



import com.alibaba.fastjson.JSONObject;
import com.yunze.apiCommon.upstreamAPI.ChenZe.SDChenZe_Api;
import com.yunze.apiCommon.utils.HttpUtil;
import com.yunze.apiCommon.utils.VeDate;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

/**
 * 查询类接口
 */
public class Query_SDCZ extends SDChenZe_Api {
    protected Logger logger = Logger.getLogger(String.valueOf(this.getClass()));

    public Query_SDCZ(Map<String, Object> init_map) {
        super(init_map);
    }

    public static void main(String[] args) throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("cd_username", "ntifTSWv");//
        map.put("cd_pwd", "dcf70cae893d8550de0f26a7e727966f");//
        map.put("cd_key", "http://223.99.228.240:60022");//
        Query_SDCZ Qy = new Query_SDCZ(map);
        List<String> list = new ArrayList<>();
        list.add("898604B21522D0005811");//


        //for (int i = 0; i <list.size() ; i++) {
         for (int i = 0; i <1 ; i++) {
              System.out.println(Qy.query(list.get(i),null));
        }
    }


    /**
     * 单卡本月套餐流量用量实时查询
     * @param simId
     */
    public  String query(String simId,String queryDate)  {
        if( queryDate!=null && queryDate.length()==6){

        }else{
            String[] arr = VeDate.getYyyyAndMm();
            queryDate = arr[0]+arr[1];
        }
        try {
            String api_url = server_Ip + "/getSimDataUsageMonthly";
            //请求参数 Json
            Map<String,Object> params = new HashMap<>();
            params.put("simId", simId);//
            params.put("queryDate", queryDate);//yyyyMM（202205）
            String  res = HttpUtil.doPost(api_url, params,headers);
            return res;
        }catch (Exception e){
            System.out.println(e);
        }
        return null;
    }


    /**
     * 单卡开关机状态实时查询
     * @param simId
     */
    public  String getOnOffStatus(String simId) {
        try {
            String api_url = server_Ip + "/getOnOffStatus";
            //请求参数 Json
            Map<String,Object> params = new HashMap<>();
            params.put("simId", simId);
            String  res = HttpUtil.doPost(api_url, params,headers);
            return res;
        }catch (Exception e){

        }
        return null;
    }




    /**
     * 单卡基本信息查询
     * @param simId
     */
    public  String getSimBasicInfo(String simId) {
        try {
            String api_url = server_Ip + "/getSimBasicInfo";
            Map<String,Object> params = new HashMap<>();
            params.put("simId", simId);
            String  res = HttpUtil.doPost(api_url, params,headers);
            return res;
        }catch (Exception e){

        }
        return null;
    }



    /**
     * 物联卡机卡分离状态查询
     * @param simId
     */
    public  String getCardBindStatus(String simId,String testType) {
        try {
            String api_url = server_Ip + "/getCardBindStatus";
            Map<String,Object> params = new HashMap<>();
            params.put("simId", simId);
            params.put("testType", testType);
            String  res = HttpUtil.doPost(api_url, params,headers);
            return res;
        }catch (Exception e){

        }
        return null;
    }







    /**
     * 修改单卡状态
     * 0:申请停机(已激活转已停机) 1:申请复机(已停机转已激活)
     * @param simId
     */
    public  String getGroupMemberDataUsage(String simId,String operType) {
        try {
            String api_url = server_Ip + "/getGroupMemberDataUsage";
            Map<String,Object> params = new HashMap<>();
            params.put("simId", simId);
            params.put("operType", operType);
            String  res = HttpUtil.doPost(api_url, params,headers);
            return res;
        }catch (Exception e){

        }
        return null;
    }



    /**
     * 单卡状态查询
     * @param simId
     */
    public  String getSimStatus(String simId) {
        try {
            String api_url = server_Ip + "/getSimStatus";
            Map<String,Object> params = new HashMap<>();
            params = new JSONObject();
            params.put("simId", simId);
            String  res = HttpUtil.doPost(api_url, params,headers);
            return res;
        }catch (Exception e){

        }
        return null;
    }


    /**
     * 单卡状态变更历史查询
     * @param simId
     */
    public  String getSimChangeHistory(String simId) {
        try {
            String api_url = server_Ip + "/getSimChangeHistory";
            Map<String,Object> params = new HashMap<>();
            params = new JSONObject();
            params.put("simId", simId);
            String  res = HttpUtil.doPost(api_url, params,headers);
            return res;
        }catch (Exception e){

        }
        return null;
    }



    /**
     * 单卡实时使用终端IMEI查询
     * @param simId
     */
    public  String getSimImei(String simId) {
        try {
            String api_url = server_Ip + "/getSimImei";
            Map<String,Object> params = new HashMap<>();
            params = new JSONObject();
            params.put("simId", simId);
            String  res = HttpUtil.doPost(api_url, params,headers);
            return res;
        }catch (Exception e){

        }
        return null;
    }





    /**
     * 单卡停机原因查询
     * @param simId
     */
    public  String getSimStopReason(String simId) {
        try {
            String api_url = server_Ip + "/getSimStopReason";
            Map<String,Object> params = new HashMap<>();
            params = new JSONObject();
            params.put("simId", simId);
            String  res = HttpUtil.doPost(api_url, params,headers);
            return res;
        }catch (Exception e){

        }
        return null;
    }





    /**
     * 单卡本月套餐流量用量实时查询
     * @param simId
     */
    public  String getSimDataMargin(String simId) {
        try {
            String api_url = server_Ip + "/getSimDataMargin";
            Map<String,Object> params = new HashMap<>();
            params = new JSONObject();
            params.put("simId", simId);
            String  res = HttpUtil.doPost(api_url, params,headers);
            return res;
        }catch (Exception e){

        }
        return null;
    }



}
